The ability to play multiple channels of sound simultaneously and the ability to initiate plays from disk were first introduced with the enhanced Sound Manager. Even with the enhanced Sound Manager, however, these capabilities are present only on computers equipped with suitable sound output hardware (such as an Apple Sound Chip). Sound Manager version 3.0 defines 2 additional bits in the Gestalt response parameter that allow you to test directly for these two capabilities.
CONST
gestaltSndPlayDoubleBuffer = 10; {play from disk routines available}
gestaltMultiChannels = 11; {multiple channels of sound supported}
Ideally, it should be sufficient to test directly, using Gestalt , for either multichannel sound capability or play-from-disk capability. If your application happens to be running under the enhanced Sound Manager, however, the two new response bits are not defined. In that case, you'll need to test also whether the Apple Sound Chip is available, because multichannel sound and play from disk are supported by the enhanced Sound Manager only if the Apple Sound Chip is available. To test for the presence of the Apple Sound Chip, you can use the Gestalt function with the gestaltHardwareAttr selector and the gestaltHasASC bit. Listing 1-21 combines these two tests into a single routine that returns TRUE if the computer supports multichannel sound.
Listing 21 Testing for multichannel play capability
FUNCTION MyCanPlayMultiChannels: Boolean;
VAR
myResponse: LongInt;
myResult: Boolean;
myErr: OSErr;
myVersion: NumVersion;
BEGIN
myResult := FALSE;
myVersion := SndSoundManagerVersion;
myErr := Gestalt(gestaltSoundAttr, myResponse);
IF myVersion.majorRev >= 3 THEN
IF (myErr = noErr) AND (BTst(myResponse, gestaltMultiChannels)) THEN
myResult := TRUE
ELSE
BEGIN
myErr := Gestalt(gestaltHardwareAttr, myResponse);
IF (myErr = noErr) AND (BTst(myResponse, gestaltHasASC)) THEN
myResult := TRUE
END;
MyCanPlayMultiChannels := myResult;
END;
The function MyCanPlayMultiChannels first tries to get the desired information by calling the Gestalt function with the gestaltSoundAttr selector. If Gestalt returns successfully and the gestaltMultiChannels bit is set in the response parameter, then multichannel play capability is present. Notice that the multichannel bit is checked only if the version of the Sound Manager is 3.0 or greater. If the version is not at least 3.0, then MyCanPlayMultiChannels calls the Gestalt function with the gestaltHardwareAttr selector. If the computer contains the Apple Sound Chip, then again multichannel play capability is present.
The gestaltHasASC bit is set only on machines that contain an Apple Sound Chip. You should test for the presence of the Apple Sound Chip only in the circumstances described above.
You could write a similar function to test for the ability to initiate a play from disk. Listing 1-22 shows an example.
Listing 22 Testing for play-from-disk capability
FUNCTION HasPlayFromDisk: Boolean;
VAR
myResponse: LongInt;
myResult: Boolean;
myErr: OSErr;
myVersion: NumVersion;
BEGIN
myResult := FALSE;
myVersion := SndSoundManagerVersion;
myErr := Gestalt(gestaltSoundAttr, myResponse);
IF myVersion.majorRev >= 3 THEN
IF (myErr = noErr) AND
(BTst(myResponse, gestaltSndPlayDoubleBuffer)) THEN
myResult := TRUE
ELSE
BEGIN
myErr := Gestalt(gestaltHardwareAttr, myResponse);
IF (myErr = noErr) AND (BTst(myResponse, gestaltHasASC)) THEN
myResult := TRUE
END;
HasPlayFromDisk := myResult;
END;
| Previous | Chapter contents | Chapter top | Section top | Next |